package com.my.xinyidaixi.Model;

import com.my.xinyidaixi.DataBase.Bean.Clothinfo;
import com.my.xinyidaixi.DataBase.Model.Over_UserModer;
import com.my.xinyidaixi.DataBase.Model.UserModel;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * Created by zw on 2017/7/21.
 */
public class GoodsItem implements Serializable{
    public int id;
    public String name;
    public int price;
    public int count;
    public  String  image_url;

    public GoodsItem(int id, String name, int price,int count,String image_url)
    {
        this.id = id;
        this.name = name;
        this.price = price;
        this.count=count;
        this.image_url=image_url;
    }

    private  static ArrayList<GoodsItem> goodlist;
    private  static ArrayList<GoodsItem> goodlist_xixie;
    private  static ArrayList<GoodsItem> goodlist_gaoduanxihu;
    private  static ArrayList<GoodsItem> goodlist_kuziqunzi;
    private  static ArrayList<GoodsItem> goodlist_peijian;
    private  static ArrayList<GoodsItem> goodlist_jiafang;
    private  static ArrayList<GoodsItem> goodlist_pijuhuli;

    private static void initdata(ArrayList<Clothinfo> info)
    {
        goodlist=new ArrayList<>();
        GoodsItem item=null;
        for(int i=0;i<info.size();i++)
        {
            if(info.get(i).getC_type().equals("上衣"))
            {
                item=new GoodsItem(i,info.get(i).getC_name(),info.get(i).getC_prise(),0,info.get(i).getC_image_url());
                goodlist.add(item);
            }

        }
    }

    private static void initadata_xixie(ArrayList<Clothinfo> info)
    {

        goodlist_xixie=new ArrayList<>();
        GoodsItem item=null;
        for(int i=0;i<info.size();i++)
        {
            if(info.get(i).getC_type().equals("大衣外套"))
            {
                item=new GoodsItem(i,info.get(i).getC_name(),info.get(i).getC_prise(),0,info.get(i).getC_image_url());
                goodlist_xixie.add(item);
            }
        }
    }

    private static void initadata_gaoduanxihu(ArrayList<Clothinfo> info)
    {
        goodlist_gaoduanxihu=new ArrayList<>();
        GoodsItem item=null;
        for(int i=0;i<info.size();i++)
        {
            if(info.get(i).getC_type().equals("鞋类"))
            {
                item=new GoodsItem(i,info.get(i).getC_name(),info.get(i).getC_prise(),0,info.get(i).getC_image_url());
                goodlist_gaoduanxihu.add(item);
            }

        }
    }

    private static void initadata_kuziqunzi(ArrayList<Clothinfo> info)
    {
        goodlist_kuziqunzi=new ArrayList<>();
        GoodsItem item=null;
        for(int i=0;i<info.size();i++)
        {
            if(info.get(i).getC_type().equals("裤子裙子"))
            {
                item=new GoodsItem(i,info.get(i).getC_name(),info.get(i).getC_prise(),0,info.get(i).getC_image_url());
                goodlist_kuziqunzi.add(item);
            }

        }
    }


    private static void initadata_peijian(ArrayList<Clothinfo> info)
    {
        goodlist_peijian=new ArrayList<>();
        GoodsItem item=null;
        for(int i=0;i<info.size();i++)
        {
            if(info.get(i).getC_type().equals("配件"))
            {
                item=new GoodsItem(i,info.get(i).getC_name(),info.get(i).getC_prise(),0,info.get(i).getC_image_url());
                goodlist_peijian.add(item);
            }

        }
    }

    private static void initadata_jiafang(ArrayList<Clothinfo> info)
    {
        goodlist_jiafang=new ArrayList<>();
        GoodsItem item=null;
        for(int i=0;i<info.size();i++)
        {
            if(info.get(i).getC_type().equals("家纺"))
            {
                item=new GoodsItem(i,info.get(i).getC_name(),info.get(i).getC_prise(),0,info.get(i).getC_image_url());
                goodlist_jiafang.add(item);
            }

        }
    }

    private static void initadata_pijuhuli(ArrayList<Clothinfo> info)
    {
        goodlist_pijuhuli=new ArrayList<>();
        GoodsItem item=null;
        for(int i=0;i<info.size();i++)
        {
            if(info.get(i).getC_type().equals("皮具护理"))
            {
                item=new GoodsItem(i,info.get(i).getC_name(),info.get(i).getC_prise(),0,info.get(i).getC_image_url());
                goodlist_pijuhuli.add(item);
            }

        }
    }

    public static ArrayList<GoodsItem> getGoodlist_xixie()
    {
        UserModel model=new Over_UserModer();
        if(goodlist_xixie==null)
        {
            initadata_xixie(model.get_cloth_info());

        }
        return goodlist_xixie;
    }

    public static ArrayList<GoodsItem> getGoodlist_gaoduanxihu()
    {
        UserModel model=new Over_UserModer();
        if(goodlist_gaoduanxihu==null)
        {
            initadata_gaoduanxihu(model.get_cloth_info());
        }
        return goodlist_gaoduanxihu;
    }

    public static ArrayList<GoodsItem> getGoodlist()
    {
        UserModel model=new Over_UserModer();
        if(goodlist==null)
        {
            initdata(model.get_cloth_info());
        }
        return goodlist;
    }

    public static ArrayList<GoodsItem> getkuziqunzilist()
    {
        UserModel model=new Over_UserModer();
        if(goodlist_kuziqunzi==null)
        {
            initadata_kuziqunzi(model.get_cloth_info());
        }
        return goodlist_kuziqunzi;
    }

    public static ArrayList<GoodsItem> getpeijianlist()
    {
        UserModel model=new Over_UserModer();
        if(goodlist_peijian==null)
        {
            initadata_peijian(model.get_cloth_info());
        }
        return goodlist_peijian;
    }

    public static ArrayList<GoodsItem> goodlist_jiafang()
    {
        UserModel model=new Over_UserModer();
        if(goodlist_jiafang==null)
        {
            initadata_jiafang(model.get_cloth_info());
        }
        return goodlist_jiafang;
    }

    public static ArrayList<GoodsItem> goodlist_pijuhuli()
    {
        UserModel model=new Over_UserModer();
        if(goodlist_pijuhuli==null)
        {
            initadata_pijuhuli(model.get_cloth_info());
        }
        return goodlist_pijuhuli;
    }
}
